package com.t2t.top.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.io.Resource;
import org.springframework.util.PropertyPlaceholderHelper;

import java.io.IOException;
import java.util.*;

/**
 * Spring自定义PropertyPlaceholderConfigurer
 */
public class CustomPropertyConfigurer extends PropertyPlaceholderConfigurer {

    @Override
    protected void loadProperties(final Properties props) throws IOException {
        System.out.println("ok");
        super.loadProperties(props);
    }

    protected String decrypt(final String propertyValue) {
        return "decrypt-" + propertyValue;
    }

    @Override
    protected String convertProperty(String propertyName, String propertyValue) {
        if (propertyName.startsWith("encrypt.")) {
            return decrypt(propertyValue);
        }
        return convertPropertyValue(propertyValue);
    }
}  